<?php
require_once '../sub/init.php';
header("Cache-control: private");
require_once 'chkUadm.php';
if(!in_array('huxuan',$QXARR))exit(noauth());
require_once ZEAI.'cache/config_up.php';
require_once ZEAI.'sub/zeai_up_func.php';
require_once ZEAI.'cache/config_vip.php';
require_once ZEAI.'cache/udata.php';
$urole = json_decode($_ZEAI['urole'],true);
if ($submitok == "addupdate" || $submitok == "modupdate") {
	if(empty($title))json_exit(array('flag'=>0,'msg'=>'请输入【互选标题】'));
	if(str_len($content)>50000)json_exit(array('flag'=>0,'msg'=>'【详细内容】请小于50000字节'));
	$title       = trimm(dataIO($title,'in',200));
	$content     = dataIO($content,'in');
	if(!empty($bmtj_data))$bmtj_data   = implode(",",$bmtj_data);;
	if(!empty($bmtj_data_px))$bmtj_data_px= dataIO($bmtj_data_px,'in',500);
	$privateC= dataIO($privateC,'in',5000);
	$bz          = dataIO($bz,'in',500);
	$wxshareT    = dataIO($wxshareT,'in',200);
	$wxshareC    = dataIO($wxshareC,'in',500);
	$ifadmlist   = (!empty($ifadmlist))?implode(",",$ifadmlist):'';
	if(!ifdatetime($jzbmtime))json_exit(array('flag'=>0,'msg'=>'请输入【截止报名时间】'));
	if(!ifdatetime($hxtime))json_exit(array('flag'=>0,'msg'=>'请输入【互选开始时间】'));
	$jzbmtime = strtotime($jzbmtime);
	$hxtime = strtotime($hxtime);
	$flag=intval($flag);
	$flag=(empty($flag) && $submitok == "addupdate")?1:$flag;
	$bmtj_data_bfb_num=intval($bmtj_data_bfb_num);
	$bmtj_data_bfb_num=($bmtj_data_bfb_num>100)?100:$bmtj_data_bfb_num;
	//用户互选人数
	foreach($urole as $RV){
		$price = 'json_hxnum'.$RV['g'];
		$price = abs(intval($$price));
		//if(empty($price))json_exit(array('flag'=>0,'msg'=>'请输入【用户互选人数】，每个等级必须大于0'));
		$json_hxnum[$RV['g']] = $price;
	}
	$json_hxnum = encode_json($json_hxnum);
	if(empty($json_hxnum))json_exit(array('flag'=>0,'msg'=>'请输入【用户互选人数】'));
	
	//报名费用
	foreach($urole as $RV){
		$price1 = 'price1_'.$RV['g'];$price1 = abs(floatval($$price1));
		$price2 = 'price2_'.$RV['g'];$price2 = abs(floatval($$price2));
		$json_price['1_'.$RV['g']] = $price1;
		$json_price['2_'.$RV['g']] = $price2;
	}
	$json_price = encode_json($json_price);
	if($submitok == "addupdate"){
		if(!empty($path_s)){
			adm_pic_reTmpDir_send($path_s,'form');
			adm_pic_reTmpDir_send(smb($path_s,'b'),'form');
			$path_s = str_replace('tmp','form',$path_s);
		}
		$db->query("INSERT INTO ".__TBL_HUXUAN__."  (title,content,path_s,bmtj_data,bmtj_data_bfb_num,bmtj_data_px,bz,ifadmlist,addtime,wxshareT,wxshareC,privateC,json_hxnum,json_price,jzbmtime,hxtime,flag) VALUES ('$title','$content','$path_s','$bmtj_data',$bmtj_data_bfb_num,'$bmtj_data_px','$bz','$ifadmlist',".ADDTIME.",'$wxshareT','$wxshareC','$privateC','$json_hxnum','$json_price','$jzbmtime','$hxtime',$flag)");	
		$id = intval($db->insert_id());
		AddLog('新增【互选相亲会】ID:'.$id.'，标题:'.$title);
	}elseif($submitok=='modupdate'){
		if(!ifint($id))json_exit(array('flag'=>0,'msg'=>'ID跑路了，请联系开发者【择。爱 www。zeai。cn】官方客服'));
		$row = $db->ROW(__TBL_HUXUAN__,"path_s"," id=".$id,"num");
		if (!$row)json_exit(array('flag'=>0,'msg'=>'zeai_error_db_fid'.$id));
		$data_path_s= $row[0];
		$SQL="";
		/*********** ZEAI.path_s ***********/
		//提交空，数据库有，删老
		if(empty($path_s) && !empty($data_path_s)){
			@up_send_admindel($data_path_s.'|'.smb($data_path_s,'b'));
		//提交有，数据库无
		}elseif(!empty($path_s) && empty($data_path_s)){
			//上新
			adm_pic_reTmpDir_send($path_s,'form');
			adm_pic_reTmpDir_send(smb($path_s,'b'),'form');
			$path_s = str_replace('tmp','form',$path_s);
		//提交有，数据库有
		}elseif(!empty($path_s) && !empty($data_path_s)){
			//有改动
			if($path_s != $data_path_s){
				//删老
				@up_send_admindel($data_path_s.'|'.smb($data_path_s,'b'));
				//上新
				adm_pic_reTmpDir_send($path_s,'form');adm_pic_reTmpDir_send(smb($path_s,'b'),'form');
				$path_s = str_replace('tmp','form',$path_s);
			}
		}
		AddLog('修改【互选相亲会】ID:'.$id.'，标题:'.$title);
		$db->query("UPDATE ".__TBL_HUXUAN__." SET title='$title',content='$content',bmtj_data='$bmtj_data',bmtj_data_bfb_num=$bmtj_data_bfb_num,bmtj_data_px='$bmtj_data_px',path_s='$path_s',bz='$bz',ifadmlist='$ifadmlist',wxshareT='$wxshareT',wxshareC='$wxshareC',privateC='$privateC',json_hxnum='$json_hxnum',json_price='$json_price',jzbmtime='$jzbmtime',hxtime='$hxtime',flag='$flag' WHERE id=".$id);
	}
	json_exit(array('flag'=>1,'msg'=>'操作成功'));
}elseif($submitok=='ajax_pic_path_s_up'){
	if (ifpostpic($file['tmp_name'])){
		$dbname = setphotodbname('tmp',$file['tmp_name'],$session_uid.'_');
		if (!up_send($file,$dbname,0,$_UP['upMsize'],'6500*6500'))json_exit(array('flag'=>0,'msg'=>'图片写入失败'));
		$dbname=setpath_s($dbname);
		AddLog('【互选相亲会】上传图片->url:'.$dbname);
		json_exit(array('flag'=>1,'msg'=>'上传成功','dbname'=>$dbname));
	}else{
		json_exit(array('flag'=>0,'msg'=>'zeai_tmp_name_error'));
	}
}elseif($submitok=='ajax_del'){
	if (!ifint($id))json_exit(array('flag'=>0,'msg'=>'互选不存在或已被删除'));
	$rt = $db->query("SELECT path_s,title FROM ".__TBL_HUXUAN__." WHERE id=".$id);
	$total = $db->num_rows($rt);
	if ($total > 0 ) {
		for($i=1;$i<=$total;$i++) {
			$row = $db->fetch_array($rt,'name');
			if(!$row) break;
			$path_s = $row['path_s'];$title = $row['title'];
			if(!empty($path_s)){$B = smb($path_s,'b');@up_send_admindel($path_s.'|'.$B);}
		}
		$db->query("DELETE FROM ".__TBL_HUXUAN__." WHERE id=".$id);
		$db->query("DELETE FROM ".__TBL_HUXUAN_BMU__." WHERE fid=".$id);
		$db->query("DELETE FROM ".__TBL_HUXUAN_HXU__." WHERE fid=".$id);
		AddLog('删除【互选相亲会】->ID:'.$id.'，标题:'.$title);
	}
	json_exit(array('flag'=>1,'msg'=>'删除成功'));
}elseif($submitok=='ajax_flag'){//1报名中，2进行中，3结束
	if (!ifint($id))callmsg("ID跑路了","-1");
	$row = $db->ROW(__TBL_HUXUAN__,"flag","id=".$id,"num");
	if(!$row){
		alert_adm("您要操作的信息不存在","-1");
	}else{
		$flag = $row[0];
		$SQL = "";
		switch($flag){
			case"-1":$SQL="flag=1";break;
			case"0":$SQL="flag=1";break;
			case"1":$SQL="flag=-1";break;
		}
		$db->query("UPDATE ".__TBL_HUXUAN__." SET ".$SQL." WHERE id=".$id);
		AddLog('【互选相亲会】状态修改->id:'.$id);
		json_exit(array('flag'=>1,'msg'=>'设置成功'));
	}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="<?php echo HOST;?>/res/www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="js/Sortable1.6.1.js"></script>
<link href="css/main.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css">
<style>
td.tdLbgHUI{background-color:#eee}
.tips,.tips2{font-size:12px}
.ifadmlist{padding:0 10px;border:#eee 1px solid;background-color:#F5F6FA;margin-bottom:10px;text-align:center;line-height:150%;}
.ifadmlist li{width:150px;text-align:left;height:100px;text-align:center;display:inline-block}
.ifadmlist li img{margin-right:6px;display:block;margin:15px auto 5px auto}
.ifadmlist .brr{margin:15px 0;padding-top:15px;border-top:#eee 1px solid;line-height:200%;color:#999}
.listdatabox{padding:10px 0}
.listdatabox li{display:inline-block;padding:1px 5px;border:#ddd 1px solid;margin:3px;border-radius:3px;color:#888}
.table0 td{font-size:14px;padding:5px 0;text-align:left}
.table0 td input[type="text"]{margin:0 5px}
.listadd{min-width:900px;width:98%;margin:10px 20px 20px 20px}
.listadd td{text-align:center}
img.m{width:90px}
.box{min-width:1100px;padding:0}
</style>
<!-- editor -->
<link rel="stylesheet" href="editor/themes/default/default.css" />
<script charset="utf-8" src="editor/kindeditor.js?1"></script>
<script charset="utf-8" src="editor/lang/zh_CN.js?1"></script>
<script>
var editor;
KindEditor.ready(function(K){
  editor=K.create('textarea[name="content"]',{
	resizeType :1,
	cssData:'body {font-family: "微软雅黑"; font-size: 14px}',
	minWidth : 400,
	allowPreviewEmoticons : true,
	allowImageUpload : true,
	afterBlur:function(){this.sync();},
	items : [
		'undo','redo','fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline','removeformat', '|', 'insertorderedlist','insertunorderedlist', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull','lineheight','|',
		'selectall','quickformat', '|','image','multiimage','media', '|','plainpaste','wordpaste','hr', 'link', 'unlink','baidumap', '|','clearhtml','source', '|','preview','fullscreen']
  });
});
var up2='<?php echo $_ZEAI['up2'];?>/',upMaxMB=<?php echo $_UP['upMaxMB']; ?>;
</script>
<!--editor end -->
</head>
<body>
<div class="box">
	<div class="boxL"><a href="huxuan.php" class='ed'>互选相亲会</a></div>
	<div class="boxR">
		<?php
        if ($submitok == 'add' || $submitok == 'mod'){
            if ($submitok == 'add'){
                $bmtj_data_px = 'rz_mob,rz_identity,rz_photo,bfb,photo,sex,mysex1,mysex2,vip';
                $ifadmlist=array();
            }else{
                if(!ifint($id))alert_adm("ID去向不明","-1");
                $row = $db->ROW(__TBL_HUXUAN__,"*","id=".$id,"name");
                if ($row){
                    $id           = $row['id'];
                    $title        = dataIO($row['title'],'out');
                    $content      = dataIO($row['content'],'out');
                    $jzbmtime     = $row['jzbmtime'];
                    $hxtime       = $row['hxtime'];
                    $wxshareT     = dataIO($row['wxshareT'],'wx');
                    $wxshareC     = dataIO($row['wxshareC'],'wx');
                    $privateC     = dataIO($row['privateC'],'wx');
                    $path_s  = $row['path_s'];
                    $addtime = $row['addtime'];
                    $flag    = $row['flag'];
                    $ifadmlist    = explode(',',$row['ifadmlist']);
                    $json_hxnum   = $row['json_hxnum'];
                    $json_price   = $row['json_price'];
                    $bmtj_data_bfb_num = $row['bmtj_data_bfb_num'];
                    $bmtj_data   = $row['bmtj_data'];
                    $bmtj_data_px= $row['bmtj_data_px'];
                }
            }?>
            <form id="ZEAI_FORM">
            <table class="table size2 W98_" style="margin:0 auto">
            <tr><td class="tdL"><font class="Cf00">*</font> 互选标题</td><td class="tdR"><input name="title" id="title" type="text" class="input size2 W600" value="<?php echo $title;?>" maxlength="200"   autocomplete="off" /></td></tr>
            <tr>
              <td class="tdL"><font class="Cf00">*</font> 活动状态</td><td class="tdR">
                <input type="radio" name="flag" value="-1" id="parent_1" class="radioskin"<?php echo ($flag == -1)?' checked':'';?>><label for="parent_1" class="radioskin-label"><i class="i1"></i><b class="W100">已隐藏</b></label>
                <input type="radio" name="flag" value="1" id="parent1" class="radioskin"<?php echo ($flag == 1)?' checked':'';?>><label for="parent1" class="radioskin-label"><i class="i1"></i><b class="W100">报名中</b></label>
                <input type="radio" name="flag" value="2" id="parent2" class="radioskin"<?php echo ($flag == 2)?' checked':'';?>><label for="parent2" class="radioskin-label"><i class="i1"></i><b class="W100">互选中</b></label>
                <input type="radio" name="flag" value="3" id="parent3" class="radioskin"<?php echo ($flag == 3)?' checked':'';?>><label for="parent3" class="radioskin-label"><i class="i1"></i><b class="W100">已结束</b></label>
              
              </td></tr>
            <tr><td class="tdL"><font class="Cf00">*</font> 顶部图片</td><td class="tdR C8d">
                <div class="picli100" id="picli_path">
                  <li class="add" id="path_add"></li>
                  <?php if(!empty($path_s)){
                        echo '<li><img src="'.$_ZEAI['up2'].'/'.$path_s.'"><i></i></li><br><br><br><span class="tips" >先删除后更换</span>';
                    }?>
                </div>
              <?php if(empty($path_s)){?><br><span class="tips" ><br>请配上一张海报图，更具吸引力，推荐尺寸：900×500像数，图片格式.gif/.jpg/.png，推荐65%品质jpg</span><?php }?>
            </td></tr>
            <tr>
            <td class="tdL"><font class="Cf00">*</font> 截止报名时间</td>
            <td class="tdR"><input name="jzbmtime" id="jzbmtime" type="text" class="input size2 W300" maxlength="100" value="<?php echo YmdHis($jzbmtime);?>"  autocomplete="off" /><span class="tips">请选择大于现在1天以上的日期，超过此时间，将不能报名</span></td>
            </tr>
            <tr>
            <td class="tdL"><font class="Cf00">*</font> 互选开始时间</td>
            <td class="tdR"><input name="hxtime" id="hxtime" type="text" class="input size2 W300" maxlength="100" value="<?php echo YmdHis($hxtime);?>"  autocomplete="off" /><span class="tips">请选择大于大于截止报名时间，超过此时间，用户可以互选，活动开正式开始，如需结束，后台修改状态</span></td>
            </tr>
            <tr>
            <td class="tdL"><font class="Cf00">*</font> 用户互选人数</td>
            <td class="tdR">
                <?php
                $json_hxnum = json_decode($json_hxnum,true);
                sort($urole);
                if (is_array($urole) && count($urole)>0){?>
                <table class="table0" style="margin:0">
                <?php
                foreach($urole as $RV){
                    $grade = $RV['g'];?>
                    <tr>
                    <td align="left"><?php echo uicon_grade_all($grade); ?> <font style="vertical-align:middle"><?php echo $RV['t'];?></font></td>
                    <td width="100" align="left"><input name="json_hxnum<?php echo $grade;?>" type="text" class="W50" maxlength="5" value="<?php echo $json_hxnum[$grade];?>"> 人</td>
                    </tr>
                    <?php
                }?>
                </table>
                <?php }else{
                    echo "<div class='nodatatipsS'>暂无用户组<br><br><a class='btn size1' href='urole.php'>新增用户组</a></div>";
                }
                ?>
            </td>
            </tr>
            <!--互选/报名条件-->
            <tr>
            <td class="tdL">互选/报名条件</td>
            <td class="tdR">
                <style>
                .stepbox .stepli3{margin-top:5px}
                .stepbox .stepli3 li{height:32px;padding:5px 10px;float:left;margin:5px;border:#ddd 1px solid;cursor:move;background-color:#f8f8f8;border-radius:3px}
                .FVerdana{background-color:#fff}
                </style>
                <dd class="stepbox" id="stepbox3">
                    <div class="stepli3">
                        <?php
                        $bmtj_dataARR    = explode(',',$bmtj_data);
                        $bmtj_data_pxARR = explode(',',$bmtj_data_px);
                        if (count($bmtj_data_pxARR) >= 1 && is_array($bmtj_data_pxARR)){
                            foreach ($bmtj_data_pxARR as $k=>$V) {?>
                                <li><input type="checkbox" name="bmtj_data[]" id="bmtj_data_<?php echo $V;?>" class="checkskin bmtj_li" value="<?php echo $V;?>"<?php echo (in_array($V,$bmtj_dataARR))?' checked':'';?>><label for="bmtj_data_<?php echo $V;?>" class="checkskin-label"><i class="i1"></i>
                                <b class="<?php ($V == 'bfb')?'W200':'W100';?>"><?php echo chatContact_data_title($V);?>
                                <?php if ($V == 'bfb'){?> <input name="bmtj_data_bfb_num" type="text" class="W50 FVerdana" maxlength="3" value="<?php echo $bmtj_data_bfb_num;?>"> %<?php }?>
                                </b></label></li>
                                <?php
                            }
                        }
                        ?>
                    </div>
                    <div class="clear"></div>
                </dd>
                <font class="S12 C999">可以按住不放拖动项目调整前后顺序，系统检查规则(从左到右)，选中请打勾，选中将进行验证和检查，不符合将不能报名（自动弹出引导页面完善），如全不选将忽略检查</font>
                <input name="bmtj_data_px" id="bmtj_data_px" type="hidden" value="<?php echo $bmtj_data_px;?>">    
            </td>
            </tr>
            <!--报名费用-->
            <tr><td class="tdL">报名费用</td>
            <td class="tdR">
                <?php
                $json_price = json_decode($json_price,true);
                if (is_array($urole) && count($urole)>0){?>
                <table class="table0" style="margin:0">
                    <?php
                    foreach($urole as $RV){
                        $grade = $RV['g'];?>
                        <tr>
                        <td align="left"> <font style="vertical-align:middle" class="B"><?php echo $RV['t'];?></font> <i class="ico Caaa S18" style="margin:0 5px;vertical-align:middle">&#xe62d;</i> </td>
                        <td width="300" align="left">
                         <?php echo uicon_grade_all($grade,1,1); ?>男 <input name="price1_<?php echo $grade;?>" id="price1_<?php echo $grade;?>" type="text" class="size2 W50 FVerdana" maxlength="6" value="<?php echo floatval($json_price['1_'.$grade]);?>"> 元　
                         <?php echo uicon_grade_all($grade,1,2); ?>女 <input name="price2_<?php echo $grade;?>" id="price2_<?php echo $grade;?>" type="text" class="size2 W50 FVerdana" maxlength="6" value="<?php echo floatval($json_price['2_'.$grade]);?>"> 元
                        </td>
                        </tr>
                        <?php
                    }?>
                </table>
                <?php }else{
                    echo "<div class='nodatatipsS'>暂无用户组<br><br><a class='btn size1' href='urole.php'>新增用户组</a></div>";
                }
                ?>
                <font class="tips">填0将免费报名，反之将支付费用后报名</font>
            </td></tr>
            <!--微信通知-->
            <tr><td class="tdL">微信通知</td><td class="tdR">
              <div class='ifadmlist'>
                <div>
                <?php 
                $rt=$db->query("SELECT id,truename,path_s,sex FROM ".__TBL_ADMIN__." WHERE flag=1 AND subscribe=1 AND openid<>''");
                $total = $db->num_rows($rt);
                if ($total == 0) {
                    echo "<br><font class='Cf00'>..暂无管理员/红娘..</font><br>";
                } else {
                    for($i=1;$i<=$total;$i++) {
                        $rows = $db->fetch_array($rt,'num');
                        if(!$rows) break;
                        $admid   = $rows[0];
                        $truename = dataIO($rows[1],'out');
                        $path_s   = $rows[2];
                        $sex      = $rows[3];
                        if(!empty($path_s)){
                            $path_s_str = '<img src="'.$_ZEAI['up2'].'/'.$path_s.'" class="photo_s">';
                        }else{
                            $path_s_str = '<img src="'.HOST.'/res/photo_s'.$sex.'.png'.'" class="photo_s">';
                        }
                        ?>
                  <li><?php echo $path_s_str;?><input type="checkbox" name="ifadmlist[]" id="ifadmlist_<?php echo $admid;?>" class="checkskin" value="<?php echo $admid;?>"<?php echo (in_array($admid,$ifadmlist))?' checked':'';?>><label for="ifadmlist_<?php echo $admid;?>" class="checkskin-label"><i class="i1"></i><b><?php echo $truename;?></b></label><div class="S12 C999">ID:<?php echo $admid;?></div></li>
                    <?php
                    }
                }
                ?>
                  </div>
                <div class="clear"></div>
                <div class="brr">
                  <img src="images/!.png" width="14" height="14" valign="middle"> <span class="tips2 picmiddle">有人报名后，管理员/红娘在微信公众号会收到报名信息　　注：必须绑定关注后生效，如下：</span><br><b>主后台</b>顶部【工作台】<img src="images/d2.gif">左下角【管理员用户】<img src="images/d2.gif">点【修改】进入绑定，如果没有请先新增
                  
                  <br><b>CRM</b>顶部右上角【设置】<img src="images/d2.gif">左侧【红娘管理】<img src="images/d2.gif">点【修改】进入绑定，如果没有请先新增
                  <div class="clear"></div>
                  </div>
                </div>
            </td></tr>
            <tr><td class="tdL"><font class="Cf00">*</font> 活动说明</td><td class="tdR"><img src="images/!.png" width="14" height="14" valign="middle"> <span style="font-size:12px;vertical-align:middle;color:#999">如果从公众号编辑器或外部网页或Word里拷入内容请先过虑垃圾代码，请点击下方</span> <img src="images/cclear.png" class="picmiddle"> <span class="tips picmiddle">图标，然后插入文字内容</span><textarea name="content" id="content" class="textarea_k" style="width:100%;height:300px" ><?php echo $content;?></textarea></td></tr>
            
            
            <tr><td class="tdL tdLbgHUI"><font class="Cf00">*</font> 微信分享标题</td><td class="tdR"><textarea name="wxshareT" id="wxshareT" rows="3" class="W700 S14"><?php echo $wxshareT;?></textarea></td></tr>
            <tr><td class="tdL tdLbgHUI"><font class="Cf00">*</font> 微信分享描述</td><td class="tdR"><textarea name="wxshareC" id="wxshareC" rows="3" class="W700 S14"><?php echo $wxshareC;?></textarea></td></tr>
        
            <tr><td class="tdL">隐私条款</td><td class="tdR"><textarea name="privateC" rows="12" class="W700" placeholder="打开前端互选详情页弹窗【隐私条款】，内容小于10个字将自动关闭不显示，内容请控制在2000字以内"><?php echo $privateC;?></textarea></td></tr>
            <tr><td class="tdL">备注</td><td class="tdR"><textarea name="bz" rows="4" class="W700" placeholder="备注(500字节内，没有请留空)，不对外展示，内部备注"><?php echo $bz;?></textarea></td></tr>
            </table>
            <input name="submitok" type="hidden" value="<?php echo $submitok.'update';?>" />
            <input name="path_s" id="path_s" type="hidden" value="" />
            <?php if ($submitok == 'mod'){?><input name="id" type="hidden" value="<?php echo $id;?>" /><?php }?>
            </form>
        <?php }else{ ?>
            <!-- LIST -->
            <div class="topsearch">
            	<button type="button" class="btn size2" onClick="zeai.openurl('huxuan.php?submitok=add')"><i class="ico">&#xe622;</i> 新增互选项目</button>
                <div class="rbox">
                <form name="ZEAI_CN__form1" method="get" action="<?php echo SELF; ?>">
                    <input name="Skey" type="text" id="Skey" maxlength="25" class="input size2 W200" placeholder="输入互选项目ID/标题" value="<?php echo $Skey; ?>">
                    <input type="hidden" name="p" value="<?php echo $p;?>" />
                    <button type="submit" class="btn size2"><i class="ico">&#xe6c4;</i> 搜索</button>
                </form>
                </div>
            </div>            
            <?php
            $SQL = "";
            $Skey = trimm($Skey);
            if (ifint($Skey)){
                $SQL = " WHERE id=$Skey ";
            }elseif(!empty($Skey)){
                $SQL = " WHERE title LIKE '%".$Skey."%' ";
            }
            $rt = $db->query("SELECT *,(SELECT COUNT(id) FROM ".__TBL_HUXUAN_BMU__." WHERE fid=F.id) AS Unum,(SELECT COUNT(id) FROM ".__TBL_HUXUAN_HXU__." WHERE fid=F.id) AS hxnum FROM ".__TBL_HUXUAN__." AS F ".$SQL." ORDER BY id DESC LIMIT ".$_ADM['admLimit']);
            $total = $db->num_rows($rt);
            if ($total <= 0 ){
                echo "<div class='nodataico'><i></i>暂无内容<br><a class='aQINGed' href='huxuan.php?submitok=add'>新增互选</a></div>";
            } else {
                $page_skin=2;$pagemode=3;$pagesize=$_ADM['admPageSize'];require_once ZEAI.'sub/page.php';?>
                <form id="www_zeai_cn_FORM" method="get" action="<?php echo SELF; ?>">
                    <table class="tablelist" >
                    <tr>
                    <th width="20"><input type="checkbox" id="checkboxall1" class="checkskin checkboxall"><label for="checkboxall1" class="checkskin-label"><i class="i1"></i></label></th>
                    <th width="40">ID</th>
                    <th width="60" align="center">主图</th>
                    <th width="15" align="center">&nbsp;</th>
                    <th width="220" align="left">互选相亲会标题</th>
                    <th width="66" align="center">浏览二维码/网址</th>
                    <th align="center">&nbsp;</th>
                    <th width="60" align="center">报名用户/操作</th>
                    <th width="60" align="center">互选人数</th>
                    <th width="60" align="center">人气</th>
                    <th width="70" align="center">发布时间</th>
                    <th width="60" align="center">状态</th>
                    <th width="100" align="center">操作</th>
                    </tr>
                    <?php
                    for($i=1;$i<=$pagesize;$i++) {
                        $rows = $db->fetch_array($rt,'name');
                        if(!$rows) break;
                        $id = $rows['id'];
                        $title = dataIO($rows['title'],'out');
                        $title = str_replace($Skey,"<font color=red><b>".$Skey."</b></font>",$title);
                        $addtime = YmdHis($rows['addtime']);
                        $path_s  = $rows['path_s'];
                        $flag    = $rows['flag'];
                        $Unum  = $rows['Unum'];
                        $hxnum = $rows['hxnum'];
                        $click = $rows['click'];
                        if(!empty($path_s)){
                            $path_s_url = $_ZEAI['up2'].'/'.$path_s;
                            $path_s_str = '<img src="'.$path_s_url.'">';
                        }else{
                            $path_s_url = '';
                            $path_s_str = '';
                        }
                        $path_s_url = (!empty($path_s))?$_ZEAI['up2'].'/'.$path_s:HOST.'/res/noP.gif';
                        $path_s_str = '<img src="'.$path_s_url.'" class="m">';
                        $ewmurl=urlencode(HOST.'/m/huxuan_detail.php?id='.$id);//.'&admid='.$session_uid
                    ?>
                    <tr id="tr<?php echo $id;?>">
                        <td width="20" height="40"><input type="checkbox" name="list[]" value="<?php echo $id; ?>" uid="<?php echo $senduid; ?>" id="id<?php echo $id; ?>" class="checkskin"><label for="id<?php echo $id; ?>" class="checkskin-label"><i class="i1"></i></label>
                        </td>
                      <td width="40" class="C999"><label for="id<?php echo $id; ?>"><?php echo $id;?></label></td>
                        <td width="60" align="center">
                        
                <a href="javascript:;" class="zoom" onClick="parent.piczoom('<?php echo smb($path_s_url,'b'); ?>');"><?php echo $path_s_str; ?></a>        
                        
                
                        </td>
                        <td width="15" align="center">&nbsp;</td>
                        <td width="220" align="left" class="S14"><a href="huxuan.php?submitok=mod&id=<?php echo $id;?>&p=<?php echo $p;?>"><?php echo $title;?></a></td>
                        <td width="66" align="center"><a href="javascript:;" onclick="parent.zeai.iframe('【<?php echo $title;?>】二维码','u_ewm.php?url=<?php echo $ewmurl;?>&ifshowurl=1',400,400);" title="放大二维码/复制链接网址" class="zoom">
                <img src="images/ewm.gif" class="ewmpic">
                </a></td>
                        <td align="center">&nbsp;</td>
                        <td width="60" align="center"><a href="javascript:;" class="<?php echo ($Unum >0)?'aHONG':'aHUI';?>" onClick="zeai.iframe('【<?php echo trimhtml($title);?>】参与用户','huxuan_u.php?fid=<?php echo $id;?>')"><?php echo $Unum;?></a></td>
                        <td width="60" align="center"><?php echo $hxnum;?></td>
                        <td width="60" align="center"><?php echo $click;?></td>
                      <td width="70" align="center" class="C999"><?php echo $addtime;?></td>
                      <td width="60" align="center" class="lineH200" onClick="zeai.openurl('huxuan.php?submitok=mod&id=<?php echo $id;?>&p=<?php echo $p;?>');">
                            <?php if($flag==-1){?><a clsid="<?php echo $id;?>" class="aHEI">已隐藏</a><?php }?>
                            <?php if($flag==1){?><a clsid="<?php echo $id;?>" class="aLAN">报名中</a><?php }?>
                            <?php if($flag==2){?><a clsid="<?php echo $id;?>" class="aHUANG">互选中</a><?php }?>
                            <?php if($flag==3){?><a clsid="<?php echo $id;?>" class="aLV">已结束</a><?php }?>
                      </td>
                      <td width="100" align="center">
                      <a href="huxuan.php?submitok=mod&id=<?php echo $id;?>&p=<?php echo $p;?>" class="editbtn"></a>
                      <a class="delbtn" clsid="<?php echo $id;?>"></a>
                      </td>
                      </tr>
                    <?php } ?>
                </table>
                <?php if ($total > $pagesize){?>
                <div class="listbottombox" style="text-align:center">
                    <input type="checkbox" id="checkboxall2" class="checkskin checkboxall"><label for="checkboxall2" class="checkskin-label"><i class="i1"></i></label>　
                    <input type="hidden" name="submitok" id="submitok" value="" />
                    <?php echo '<div class="pagebox">'.$pagelist.'</div>'; ?>
                </div>
                <?php }?>
                </form>
                <script>
                var bg = '<?php echo $_Style['list_bg']; ?>',overbg = '<?php echo $_Style['list_overbg']; ?>',selectbg = '<?php echo $_Style['list_selectbg']; ?>';
                zeai.listEach('.delbtn',function(obj){
                    obj.onclick = function(){
                        var id = parseInt(obj.getAttribute("clsid"));
                        zeai.confirm('<b class="S18">★请慎重★　确定真的要删除么？</b><br>删除后将同步删除对应的用户报名数据等',function(){
                            zeai.ajax({url:'huxuan'+zeai.ajxext+'submitok=ajax_del&id='+id},function(e){var rs=zeai.jsoneval(e);
                                zeai.msg(0);zeai.msg(rs.msg);
                                if(rs.flag==1){setTimeout(function(){location.reload(true);},1000);}
                            });
                        });
                    }
                });
                zeai.listEach('.flag',function(obj){
                    obj.onclick = function(){
                        var id = parseInt(obj.getAttribute("clsid"));
                        zeai.ajax({url:'huxuan'+zeai.ajxext+'submitok=ajax_flag&id='+id},function(e){var rs=zeai.jsoneval(e);
                            zeai.msg(0);zeai.msg(rs.msg);
                            if(rs.flag==1){setTimeout(function(){location.reload(true);},1000);}
                        });
                    }
                });
                </script>
                <script src="js/zeai_tablelist.js?<?php echo $_ZEAI['cache_str'];?>"></script>
            <?php }?>
        <?php }?>
	</div>
    <div class="clear"></div>
</div>
<?php if ($submitok == 'add' || $submitok == 'mod'){?>
	<div class="savebtnbox"><button type="button" class="btn size3" id="save">保存并发布</button></div>
	<script>
    <?php if($submitok=='mod'){?>
    window.onload=function(){
        path_s_mod();
        function path_s_mod(){
            var i=zeai.tag(picli_path,'i')[0],img=zeai.tag(picli_path,'img')[0];
            if(zeai.empty(i))return;
            path_add.hide();
            var src=img.src.replace(up2,'');
            path_s.value=src;
            i.onclick = function(){zeai.confirm('亲~~确认删除么？',function(){img.parentNode.remove();path_add.show();path_s.value='';});}
            img.onclick = function(){parent.piczoom(up2+src.replace('_s.','_b.'));}
        }
    }
    <?php }?>
    zeai.photoUp({
        btnobj:path_add,
        upMaxMB:upMaxMB,
        url:"huxuan"+zeai.extname,
        submitok:"ajax_pic_path_s_up",
        end:function(rs){
            zeai.msg(0);zeai.msg(rs.msg);
            if (rs.flag == 1){
                picli_path.append('<li><img src="'+up2+rs.dbname+'"><i></i></li>');
                path_s.value=rs.dbname;
                path_add.hide();
                var i=zeai.tag(o(picli_path),'i')[0],img=zeai.tag(o(picli_path),'img')[0];
                i.onclick = function(){zeai.confirm('亲~~确认删除么？',function(){img.parentNode.remove();path_add.show();path_s.value='';});}
                img.onclick = function(){parent.piczoom(up2+rs.dbname.replace('_s.','_b.'));}
            }
        }
    });
    function drag_init3(){(function (){[].forEach.call(stepbox3.getElementsByClassName('stepli3'), function (el){Sortable.create(el,{group: 'zeai_reg3',animation:150});});})();}drag_init3();
    save.onclick = function(){
        zeai.confirm('互选查看地址请返回到【列表管理页】用手机扫码【二维码】',function(){
            var DATAPX=[];
            zeai.listEach('.bmtj_li',function(obj){DATAPX.push(obj.value);});
            bmtj_data_px.value=DATAPX.join(",");
            zeai.ajax({url:'huxuan'+zeai.extname,form:ZEAI_FORM},function(e){var rs=zeai.jsoneval(e);
                zeai.msg(rs.msg);if(rs.flag==1)setTimeout(function(){zeai.openurl('huxuan'+zeai.ajxext+'p=<?php echo $p;?>');},1000);
            });
        });
    }
    </script>
<?php }?>
<script src="laydate/laydate.js"></script>
<script>
laydate.render({
	theme: 'molv'
	,elem: '#jzbmtime'
	,type: 'datetime'
}); 
laydate.render({
	theme: 'molv'
	,elem: '#hxtime'
	,type: 'datetime'
}); 
</script>
<?php
function chatContact_data_title($var) {
	switch ($var){
		case 'rz_mob':$t = '完成手机认证';break;
		case 'rz_identity':$t = '完成实名认证';break;
		case 'rz_photo':$t = '完成真人认证';break;
		case 'bfb':$t = '资料完整度达';break;
		case 'photo':$t = '有头像且已审';break;
		case 'sex':$t = '对方必须异性';break;
		case 'mysex1':$t = '报名者为男性';break;
		case 'mysex2':$t = '报名者为女性';break;
		case 'vip':$t = 'VIP用户';break;
	}
	return $t;
}
require_once 'bottomadm.php';?>